/*    */ package com.zimbra.cs.dav.service.method;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.dav.DavContext;
/*    */ import com.zimbra.cs.dav.DavElements;
/*    */ import com.zimbra.cs.dav.DavException;
/*    */ import com.zimbra.cs.dav.property.Acl.Ace;
/*    */ import com.zimbra.cs.dav.resource.DavResource;
/*    */ import com.zimbra.cs.dav.resource.MailItemResource;
/*    */ import com.zimbra.cs.dav.service.DavMethod;
/*    */ import java.io.IOException;
/*    */ import java.util.ArrayList;
/*    */ import java.util.List;
/*    */ import org.dom4j.Document;
/*    */ import org.dom4j.Element;
/*    */ import org.dom4j.QName;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class Acl
/*    */   extends DavMethod
/*    */ {
/*    */   public static final String ACL = "ACL";
/*    */   
/*    */   public String getName()
/*    */   {
/* 41 */     return "ACL";
/*    */   }
/*    */   
/*    */   public void handle(DavContext ctxt) throws DavException, IOException, ServiceException {
/* 45 */     DavResource rs = ctxt.getRequestedResource();
/* 46 */     if ((!rs.isCollection()) || (!(rs instanceof MailItemResource))) {
/* 47 */       throw new DavException("acl not implemented for non-collection resource", 501);
/*    */     }
/* 49 */     if (!ctxt.hasRequestMessage()) {
/* 50 */       throw new DavException("empty request", 400);
/*    */     }
/* 52 */     Document reqMsg = ctxt.getRequestMessage();
/* 53 */     Element acl = reqMsg.getRootElement();
/* 54 */     if (!acl.getQName().equals(DavElements.E_ACL))
/* 55 */       throw new DavException("request does not start with acl element", 400);
/* 56 */     List<Element> aceElements = acl.elements(DavElements.E_ACE);
/* 57 */     ArrayList<Acl.Ace> aceList = new ArrayList();
/* 58 */     for (Element ace : aceElements) {
/* 59 */       aceList.add(new Acl.Ace(ace));
/*    */     }
/* 61 */     MailItemResource mir = (MailItemResource)rs;
/* 62 */     mir.setAce(ctxt, aceList);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/dav/service/method/Acl.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */